﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WgFrame.Utils;
using WgFrame.Net;

public enum AttributeType
{
    /// <summary>
    /// 生命值
    /// </summary>
    HP,

    /// <summary>
    /// 攻击
    /// </summary>
    ATK,
    /// <summary>
    /// 物理防御
    /// </summary>
    DEF,

    /// <summary>
    /// 魔法防御
    /// </summary>
    RGS,

    /// <summary>
    /// 命中率
    /// </summary>
    DEX,

    /// <summary>
    /// 暴击率
    /// </summary>
    CRT,
    /// <summary>
    /// 回避率
    /// </summary>
    EVD,
    /// <summary>
    /// 抗暴率
    /// </summary>
    KBL,

    /// <summary>
    /// 伤害加成
    /// </summary>
    AMP,

    /// <summary>
    /// 技能加深
    /// </summary>
    SkillUp,

    /// <summary>
    /// 技能抗性
    /// </summary>
    SkillRes,

    /// <summary>
    /// 伤害减免
    /// </summary>
    DamageRes,

    /// <summary>
    /// 出场能量
    /// </summary>
    Energy,

    Count
}

public class Attribute
{
    public static string[] Names = new string[] { "生命", "攻击", "物防", "法防", "命中", "暴击", "闪避", "抗暴", "伤害加成", "技能加深", "技能抗性", "伤害减免", "出场能量" };

    private readonly Dictionary<AttributeType, int> data = new Dictionary<AttributeType, int>();

    public Attribute()
    {
        data = new Dictionary<AttributeType, int>();
        for (int i = (byte)AttributeType.HP; i < (byte)AttributeType.Count; i++)
        {
            data.Add((AttributeType)i, 0);
        }
    }

    public Attribute(Hashtable hashtable)
    {
        data = new Dictionary<AttributeType, int>();
        for (byte i = (byte)AttributeType.HP; i < (byte)AttributeType.Count; i++)
        {
            if (hashtable.ContainsKey(i))
            {
                data[(AttributeType)i] = (int)hashtable[i];
            }
            else
            {
                data[(AttributeType)i] = 0;
            }
        }
    }

    public void Clear()
    {
        for (int i = (byte)AttributeType.HP; i < (byte)AttributeType.Count; i++)
        {
            data[(AttributeType)i] = 0;
        }
    }

    public int Get(AttributeType attributeType)
    {
        if (data.TryGetValue(attributeType, out int value))
        {
            return value;
        }

        return 0;
    }

    public void Add(AttributeType attributeType, int value)
    {
        if (data.ContainsKey(attributeType))
        {
            data[attributeType] += value;
        }
        else
        {
            data[attributeType] = value;
        }
    }

    public Dictionary<AttributeType, int> Atts
    {
        get
        {
            return data;
        }
    }
}